from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import CSRFProtect
from redis import StrictRedis
from flask_session import Session
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand


class Config(object):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://root:mysql@127.0.0.1:3306/web_copy_msql"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    redis_host = "127.0.0.1"
    redis_port = 6379
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(redis_host, redis_port)
    SESSION_USE_SIGNER = True
    SESSION_PERMANENT = 60 * 60 * 24 * 2  # 2天


app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
CSRFProtect(app)
stric_redis = StrictRedis(app)
Session(app)
manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)


@app.route('/')
def index():
    return 'index'


if __name__ == '__main__':
    manager.run()
